package com.rainbow.config;

import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * fix sentinel 链路流控
 */
//@Configuration
public class SentinelFilterContextConfig {

    @Bean
    public FilterRegistrationBean sentinelFilterRegistration(){
        FilterRegistrationBean reg = new FilterRegistrationBean();
        reg.setFilter(new CommonFilter());
        reg.addUrlPatterns("/*");
        // 入口资源关闭聚合
        reg.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY,"false");
        reg.setName("sentinelFilter");
        reg.setOrder(1);
        return reg;
    }
}
